package com.winchain.chainbill.serfee.rx;

import com.shell.bee.acct.transaction.po.AcctTxRec;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.serfee.service.impl.ServiceFeeTranService;
import com.winchain.chainbill.tbill.base.po.TbDct;
import com.winchain.chainbill.tbill.base.po.TbRec;
import com.winchain.chainbill.tbill.biz.TBill;
import com.winchain.chainbill.tbill.biz.TBillEvent;
import com.winchain.chainbill.trade.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TBillDctReAprvDeductSerFeeSubscriber extends OnErrorNotImplementedSubscriber<TBillEvent<TbDct>> {
	@Autowired
	private ServiceFeeTranService serviceFeeTranService;
	@Autowired
	private TradeService tradeService;

	public void onApplicationEvent(TBillEvent<TbDct> t) {
		TbRec rec = t.getBill().getRec();
		TbDct dct = (TbDct) t.getBill().getSource();
		AcctTxRec tran = this.serviceFeeTranService.getDeductSerFeeTran(rec, dct, "1");
		this.tradeService.callback(tran);
	}
}
